﻿/*
 * Created by SharpDevelop.
 * User: Corrado Mio
 * Date: 01/06/2012
 * Time: 06:51
 * 
 * La classe mette a disposizione i metodi di sincronizzazione
 * associandoli direttamente all'Object (stile Java).
 * 
 *      object.Wait() -> bool
 *      object.Wait(millis) -> bool
 * 
 *      object.Pulse()
 *      object.PulseAll()
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace CSharpExt.Threading
{
    /// <summary>
    /// La classe mette a disposizione i metodi di sincronizzazione
    /// associandoli direttamente all'Object (stile Java).
    /// 
    ///     object.Wait() -> bool
    ///     object.Wait(millis) -> bool
    /// 
    ///     object.Pulse()
    ///     object.PulseAll()
    /// 
    /// Viene usato il meccanismo dell'Extension Methods!
    /// </summary>
    public static class MonitorHelper
    {
        #region Wiat/Pulse
        
        public static bool Wait(this Object locking)
        {
            return Monitor.Wait(locking);
        }

        public static bool Wait(this Object locking, int millisecondsTimeout)
        {
            return Monitor.Wait(locking, millisecondsTimeout);
        }


        public static void Pulse(this Object locking)
        {
            Monitor.Pulse(locking);
        }

        public static void PulseAll(this Object locking)
        {
            Monitor.PulseAll(locking);
        }
        
        #endregion
    }

}
